package cc.rengu.igas.share.facade.bean.cups;

import cc.rengu.oltp.service.common.enums.OltpRpcdEnum;
import cc.rengu.oltp.service.model.BizException;

import java.util.Arrays;

/**
 * F60.3.10：卡产品<p>
 * 注：机构需根据报备卡样或申请卡 bin 时的发卡项目类型确定该取值
 *
 * @author fangminwei
 * @date 2021/4/17
 */
@SuppressWarnings("AlibabaEnumConstantsMustHaveComment")
public enum F60_3_10_CardProdEnum {
    _00("00", "其他（当卡产品不在规范定义的01~82范围内时，可取值00）"),
    _01("01", "公务卡"),
    _02("02", "集中支付账户"),
    _03("03", "航空联名卡"),
    _04("04", "教育卡"),
    _05("05", "社保卡"),
    _06("06", "健康卡"),
    _07("07", "福农卡"),
    _08("08", "军人保障卡"),
    _09("09", "家庭卡"),
    _10("10", "单位结算卡"),
    _40("40", "旅游卡"),
    _80("80", "公司卡"),
    _81("81", "商旅卡"),
    _82("82", "采购卡"),
    ;

    private String code;
    private String desc;

    F60_3_10_CardProdEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    @Override
    public String toString() {
        return code + "-" + desc;
    }

    public static F60_3_10_CardProdEnum find(String code) {
        F60_3_10_CardProdEnum result = Arrays.asList(F60_3_10_CardProdEnum.values()).stream()
                .filter(e -> e.getCode().equals(code)).findFirst().orElse(null);

        if (result == null) {
            throw new BizException(OltpRpcdEnum.PARAM_IS_EMPTY_OR_NULL.getRespCode(), "找不到对应的枚举信息" + code);
        }
        return result;
    }
}
